package cn.javabb.web.controller;

import cn.javabb.core.entity.biz.SitePageDO;
import cn.javabb.core.service.biz.SitePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("/page")
@Controller
public class SitePageController {

    @Autowired
    private SitePageService sitePageService;


    @GetMapping("/{code}")
    public String page(@PathVariable("code")String code, Model model){
        SitePageDO page = sitePageService.getPage(code);
        if(null != page){
            model.addAttribute("page",page);
            return "web/view/page/page";
        }
        return "error/404";
    }

}
